﻿Public Class xtf_LISTADOconfig_validacion_

    Public Overrides Sub IniciarLista()
        Try
            gdc_general.BeginUpdate()
            gdc_general.DataSource = dtt_DataTable
            'ulg_Lista.DisplayLayout.GroupByBox.Style = Infragistics.Win.UltraWinGrid.GroupByBoxStyle.Full

            'Creacion y carga de Cuentas
            dtt_DataTable.Columns.Add("Nombre Interno")
            dtt_DataTable.Columns.Add("Nombre del Formulario")
            dtt_DataTable.Columns.Add("Validaciones")

            gdv_general.PopulateColumns(dtt_DataTable)

            Dim obj_config_validacion_ As New cls_config_validacion_
            If obj_config_validacion_.CargarTodos Then
                For Each config_validacion As cls_config_validacion_ In obj_config_validacion_.Items
                    AgregarItem(config_validacion)
                Next
            End If
            'ulg_Lista.DataBind()

            FiltrarColumnas()
            gdc_general.EndUpdate()
        Catch ex As Exception
            'Dim frmError As New frm_ErrorManager(ex.Message)
        End Try
    End Sub

    Public Function AgregarItem(ByRef config_validacion As cls_config_validacion_) As DataRow
        Dim Row As DataRow = dtt_DataTable.NewRow

        Row("Nombre Interno") = config_validacion.nombreformulario
        Row("Nombre del Formulario") = config_validacion.tituloformulario
        Row("Validaciones") = config_validacion.Totalvalidaciones

        dtt_DataTable.Rows.Add(Row)
        'ulg_Lista.Rows(ulg_Lista.Rows.Count - 1).Height = 19
        Return Row
    End Function

    Public Sub ModificarItem(ByRef config_validacion As cls_config_validacion_, ByRef ulg_row As DataRow)
        ulg_row("Nombre Interno") = config_validacion.nombreformulario
        ulg_row("Nombre del Formulario") = config_validacion.tituloformulario
        ulg_row("Validaciones") = config_validacion.Totalvalidaciones
    End Sub

    Public Overrides Sub bbi_Modificar_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) 'Handles bbi_modificar.ItemClick
        If ComprobarPermiso(PERMISOModificar) Then
            Try
                Dim config_validacion As New cls_config_validacion_
                If gdv_general.SelectedRowsCount > 0 Then
                    If config_validacion.Buscar(gdv_general.GetDataRow(gdv_general.GetSelectedRows(0))("Nombre Interno")) Then
                        bsi_estado.Caption = "Cargando..."
                        Application.DoEvents()
                        Dim obj_ABMconfig_validacion As New xtf_ABMconfig_validacion(config_validacion)
                        If obj_ABMconfig_validacion.ShowDialog = Windows.Forms.DialogResult.OK Then
                            ModificarItem(config_validacion, gdv_general.GetDataRow(gdv_general.GetSelectedRows(0)))
                        End If
                        bsi_estado.Caption = "Listo"
                    End If
                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If
    End Sub

    Public Sub New()

        Me.Cursor = Cursors.WaitCursor
        InitializeComponent()
        bbi_Nuevo.Enabled = False
        bbi_eliminar.Enabled = False
        PERMISONuevo = ""
        PERMISOModificar = ""
        PERMISOEliminar = ""
        PERMISOImprimir = ""
        Me.Text = lbl_modulo.Text : lbl_modulodescripcion.Text = "Listado de " & lbl_modulo.Text & "."
        IniciarLista()
        Me.Cursor = Cursors.Default

    End Sub

End Class